import request from "@/utils/request";
import {baseURL} from "@/config/constant";

const baseUrl = "officeExamination/";

/**
 * 考试管理信息
 * @param pagination
 * @param keyword
 */
export function page(pagination, keyword) {
    return new request({
        url: `${baseUrl}list`,
        method: "GET",
        params: {...pagination, ...keyword}
    })
}


export function addDocument(data) {
    return new request({
        url: `${baseUrl}`,
        method: "POST",
        data: data
    })
}


export function updateInfo(data) {
    return new request({
        url: `${baseUrl}`,
        method: "PUT",
        data: data
    })
}

export function deleteDocument(id) {
    return new request({
        url: `${baseUrl}?id=${id}`,
        method: "DELETE",
    })
}

export function deleteMultipleDocument(ids) {
    let filterIds = "?";
    ids.forEach(item => filterIds += `ids=${item}&`);
    filterIds = filterIds.substr(0, filterIds.length - 1);
    return new request({
        url: `${baseUrl}multiple${filterIds}`,
        method: "DELETE",
    })
}


/**
 * baseURL 服务器名称
 *
 * 删除文件
 */
export function removeFile(path) {
    path = path.slice(path.indexOf("/"), path.length);
    return new request({
        url: `${baseURL}file/?path=${path}`,
        method: "DELETE",
    })
}